import unittest
from Finance_fun.page.page10_promotion_record import PagePromotionRecord
from Finance_fun.base.get_driver import GetDriver
from Finance_fun.tool.read_json import read_json
from parameterized import parameterized


def get_promotion_record_data():
    case = read_json("data10_promotion_record.json")
    list_null = []
    for data in case.values():
        list_null.append(
            (
                data["start_date"],
                data["end_date"],
                data["username"]
             )
        )
    return list_null

class PromotionRecordTest(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        cls.driver = GetDriver.get_driver()
        cls.promotion_record = PagePromotionRecord(cls.driver)
        cls.promotion_record.page_click_login_link()
        cls.promotion_record.page_login("13129628532","W123456")


    @classmethod
    def tearDownClass(cls):
        GetDriver.quit_driver()

    @parameterized.expand(get_promotion_record_data())
    def test01_promotion_record(self,start_date,end_date,username):
        # 点击推广记录链接
        self.promotion_record.click_promotion_record()
       #输入起始时间
        self.promotion_record.input_start_time_promotion(start_date)
        #输入截止时间
        self.promotion_record.input_end_time_promotion(end_date)
        # 输入用户名
        self.promotion_record.input_username_promotion(username)
        # 点击搜索按钮
        self.promotion_record.click_search_btn_promotion()